package com.weiiew.backend.operation;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.awt.*;

/**
 * @Description
 * @Author 魏锴
 * @Date 2025/4/26
 */
@Setter
@Getter
@ToString
@AllArgsConstructor
public class MouseMove extends ComputerOperation {
    private static final long serialVersionUID = 121204894515L; // 添加 serialVersionUID
    private final int x;
    private final int y;

    public MouseMove(int x, int y, long timestamp) {
        this.x = x;
        this.y = y;
        super.setTimestamp(timestamp);
    }

    public MouseMove(long timestamp, String desc) {
        this.setTimestamp(timestamp);
        String[] split = desc.split(",");
        this.x = Integer.parseInt(split[0]);
        this.y = Integer.parseInt(split[1]);
    }

    @Override
    public String toDescriptionString() {
        return String.format("mm@%d@%d,%d",
                this.getTimestamp(), x, y);
    }

    @Override
    public void execute(Robot robot) {
        robot.mouseMove(x, y);
    }
}
